package com.ximu.service_base.exceptionhandler;

import com.ximu.common_utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @projectName: guli
 * @package: com.ximu.service_base.exceptionhandler
 * @className: GlobalExceptionHandler
 * @author: ximu
 * @description: 全局异常
 * @date: 2022/2/22 19:27
 * @version: 1.0
 */


@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    /*
     * @param null:
      * @return null
     * @author ximu
     * @description 指定异常处理类
     * @date 2022/2/22 20:06
     */

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        log.error(e.getMessage());
        e.printStackTrace();
        return Result.error().message(e.getMessage());
    }

}
